package o;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.huawei.appgallery.forum.section.buoy.action.OpenSectionDetailAction;
import com.huawei.gamebox.plugin.gameservice.view.TransferActivity;
import o.bhi.b;
import o.cab.e;
import o.cab.i;
import o.cab.j;
import o.cap.c;

public class caj extends brb implements OnClickListener, bfa, c {
    private LayoutInflater ʻ;
    private ImageView ʼ;
    private ImageView ʽ;
    private RelativeLayout ˊॱ;
    private TextView ˋ;
    private int ˋॱ;
    private Bundle ˎ = null;
    private View ˏ;
    private Class<? extends bgz> ॱ = cap.class;
    private LinearLayout ॱॱ;
    private PopupWindow ᐝ;

    public caj(Context context) {
        super(context);
    }

    public void ˋ(@Nullable Bundle bundle) {
        super.ˋ(bundle);
        this.ˎ = bundle;
    }

    public void ˏ(String str) {
        if (!TextUtils.isEmpty(str) && this.ˋ != null) {
            this.ˋ.setVisibility(0);
            this.ˋ.setText(str);
        }
    }

    public View ˊ(int i) {
        if (this.ˏ == null) {
            return null;
        }
        return this.ˏ.findViewById(i);
    }

    public View ˏ() {
        if (this.ˊ == null) {
            bqx.ॱ("ForumSectionDetailWindow", "onCreateView, context == null");
            return null;
        }
        this.ʻ = LayoutInflater.from(this.ˊ);
        this.ˏ = this.ʻ.inflate(i.ᐝॱ, null);
        this.ˏ.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener(this) {
            final /* synthetic */ caj ˏ;

            {
                this.ˏ = r1;
            }

            public void onGlobalLayout() {
                this.ˏ.ॱॱ();
            }
        });
        View findViewById = this.ˏ.findViewById(e.ˋ);
        this.ˋ = (TextView) this.ˏ.findViewById(e.ʹ);
        this.ʽ = (ImageView) this.ˏ.findViewById(e.ʽ);
        this.ʼ = (ImageView) this.ˏ.findViewById(e.ᐝᐝ);
        this.ˊॱ = (RelativeLayout) this.ˏ.findViewById(e.ʻᐝ);
        this.ʼ.setOnClickListener(this);
        this.ʽ.setOnClickListener(this);
        if (this.ˎ != null) {
            CharSequence string = this.ˎ.getString("ARG_TITLE");
            if (Logger.ˎ()) {
                bqx.ˏ("ForumSectionDetailWindow", "title is :" + string);
            }
            if (TextUtils.isEmpty(string)) {
                this.ˋ.setText(j.ˋ);
            } else {
                this.ˋ.setText(string);
            }
            try {
                this.ˋॱ = Integer.parseInt(new cau().ˎ(this.ˎ.getString("SEGMENT_URI")));
            } catch (Exception e) {
                bqx.ˋ("ForumSectionDetailWindow", "parse sectionId error");
            }
        } else {
            bqx.ˏ("ForumSectionDetailWindow", "bundle == null");
        }
        findViewById.setOnClickListener(this);
        deu ˎ = new b(this.ˊ).ˊ(this.ˎ).ˏ().ˎ(this.ॱ);
        if (ˎ instanceof cap) {
            ((cap) ˎ).ˎ((bfa) this);
            ((cap) ˎ).ˊ(ᐝ());
            ((cap) ˎ).ˊ((c) this);
        }
        ᐝ().ˋ(e.ˎˏ, ˎ, null);
        return this.ˏ;
    }

    private void ॱॱ() {
        if (ॱˎ()) {
            ॱᐝ();
            if (this.ᐝ == null && this.ॱॱ != null) {
                this.ᐝ = new PopupWindow(this.ॱॱ, -2, -2, false);
                this.ᐝ.showAsDropDown(this.ˊॱ, 0, ˏ(this.ˊ, 4) * -1, 8388613);
                this.ᐝ.setOutsideTouchable(true);
            }
        }
    }

    public static int ˏ(Context context, int i) {
        return (int) ((context.getResources().getDisplayMetrics().density * ((float) i)) + 0.5f);
    }

    private void ॱᐝ() {
        if (this.ʻ == null) {
            this.ʻ = LayoutInflater.from(this.ˊ);
        }
        this.ॱॱ = (LinearLayout) this.ʻ.inflate(i.ˏ, null);
    }

    private boolean ॱˎ() {
        bsc ˋ = bsc.ˋ();
        if (!ˋ.ˏ()) {
            return false;
        }
        ˋ.ˊ(false);
        return true;
    }

    public void onClick(View view) {
        if (view.getId() == e.ˋ) {
            ((faj) cdb.ॱ(faj.class)).ˋ(this.ˊ, this);
        } else if (view.getId() == e.ᐝᐝ) {
            ((bzx) fho.ˏ().ˋ("ForumSearch").ॱ(bzx.class)).ˎ(this.ˊ, this.ˋॱ);
        } else if (view.getId() == e.ʽ) {
            OpenSectionDetailAction.setPostCallBack(new fjc<Object>(this) {
                final /* synthetic */ caj ˏ;

                {
                    this.ˏ = r1;
                }

                public void ˎ(int i, Object obj) {
                    deu ˎ = new b(this.ˏ.ˊ).ˊ(this.ˏ.ˎ).ˏ().ˎ(this.ˏ.ॱ);
                    if (ˎ instanceof cap) {
                        ((cap) ˎ).ˎ(this.ˏ);
                        ((cap) ˎ).ˊ(this.ˏ.ᐝ());
                    }
                    this.ˏ.ᐝ().ˋ(e.ˎˏ, ˎ, null);
                }
            });
            Intent intent = new Intent(this.ˊ, TransferActivity.class);
            intent.setAction(OpenSectionDetailAction.ACTION);
            intent.putExtras(this.ˎ);
            ((faj) cdb.ॱ(faj.class)).ˎ(this.ˊ, TransferActivity.class, intent, true);
        }
    }

    public void ˋ(int i) {
        this.ˋॱ = i;
    }
}
